<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			var check=function(){
				var name=document.getElementById("t1").value;
				if(name=="")
				{
					document.getElementById("s1").innerHTML="姓名不能为空！";
					return false;
				}
				else 
				{
					var d1=document.createElement("img");
					d1.setAttribute("src","img/ok.png");
					document.getElementById("s1").innerHTML="";
					document.getElementById("s1").appendChild(d1);
				}
				
				var password=document.getElementById("t2").value;
				if(password.length<6)
				{
					document.getElementById("s2").innerHTML="密码输入有误！";
					return false;
				}
				else 
				{
					var d2=document.createElement("img");
					d2.setAttribute("src","img/ok.png");
					document.getElementById("s2").innerHTML="";
					document.getElementById("s2").appendChild(d2);
				}
				
				var old=document.getElementById("t3").value;
				if(isNaN(old)||old<=0||old>=150)
				{
					document.getElementById("s3").innerHTML="年龄必须为0~150！";
					return false;
				}
				else 
				{
					var d3=document.createElement("img");
					d3.setAttribute("src","img/ok.png");
					document.getElementById("s3").innerHTML="";
					document.getElementById("s3").appendChild(d3);
				}
				
				var phone=document.getElementById("t4").value;
				var reg=/^1\d{10}$/;
				if(!reg.test(phone))
				{
					document.getElementById("s4").innerHTML="手机验证失败！";
					return false;
				}
				else 
				{
					var d4=document.createElement("img");
					d4.setAttribute("src","img/ok.png");
					document.getElementById("s4").innerHTML="";
					document.getElementById("s4").appendChild(d4);
				}
				return true;
			}
		</script>
	</head>
	<body>
		<form action="" method="post" onsubmit="return check()">
			姓名：<input type="text" id="t1"/>
			<span id="s1"></span><br>
			密码：<input type="password" id="t2"/>
			<span id="s2"></span><br>
			年龄：<input type="text" id="t3"/>
			<span id="s3"></span><br>
			手机：<input type="text" id="t4"/>
			<span id="s4"></span><br>
			<input type="submit"/>
		</form>
	</body>
</html>
